<%@ page language="java" contentType="text/html; charset=utf-8"	pageEncoding="utf-8"%>
<%
	String id = (String) request.getAttribute("id");
%>
<html>
<head>


<script type="text/javascript">
var id=<%=id%>;
var listPageUrl="role/index.do";
var roleInfoUrl="rest/roleInfo.do";
var updateRoleUrl="rest/roleUpdate.do";


$(document).ready(function () {	
	
     $('#role-fm').form('syncLoad', roleInfoUrl+"?id="+id);
     $('#oldRolename').val($('#rolename').val());

})//end ready


function updateRole() {
    $('#role-fm').form('submit', {
        url: updateRoleUrl,        
        onSubmit: function () {
            return $(this).form('validate');
        },
        success: function (result) {
            var result = eval('(' + result + ')');
            if (result.success=='true') {
                back(listPageUrl);
            } else {
                $.messager.show({
                    title: 'Error',
                    msg: result.msg
                });
            }
        }
    });
}

function back(url){
	$.get(url, {}, function(data){
		$("#center").empty();
        $("#center").html(data);
        $.parser.parse($("#center"));
    });
}

// $.extend($.fn.validatebox.defaults.rules, { 
// 	NameVal:{
// 	validator:function(value, param){
// 		return /^[a-zA-Z]{1,10}$/.test(value);
// 	},
// 	message : '必须填写1~10个的字母'
// 	}
// }); 
</script>
</head>
<body>
		
<div class="linkbar"><a>系统</a>/<a>角色管理</a>/<a>编辑角色</a></div>
		<!-- <div class="breadcrumb">系统 &gt;&gt;角色管理&gt;&gt; 编辑角色</div> -->
		<div id="role-add" 	buttons="#role-add-buttons">
			<form id="role-fm" method="post" novalidate>
				<input type="hidden" name="id" value="<%=id %>"/>
				<input type="hidden" name="oldRolename" id="oldRolename"/>
				<div class="fitem">
					<label>角色名称:</label> 
					<input name="rolename" id="rolename" class="easyui-validatebox" required="true"
					 validType="NameVal" missingMessage="该输入项不能为空，请选择！"  />
				</div>
				<div class="fitem">
					<label>角色备注:</label>
					 <input name="roledesc" required="true"	class="easyui-validatebox" 
					 missingMessage="该输入项不能为空，请选择！" />
				</div>
			</form>
		</div>
		<div id="dlg-buttons">
			<a href="#" class="easyui-linkbutton" iconCls="icon-ok" 	onclick="updateRole()">保存</a> 
			<a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="back(listPageUrl)">返回</a>
		</div>
		

</body>
</html>